package stringExertises;

import java.util.Scanner;

/**
 * @author: snail_mount
 * @date: 20/2/3 15:55
 * @description: 模拟登陆
 * 需求：已知用户名和密码，请用程序实现模拟用户登录。总共给三次机会，登录之后，给出相应的提示
 * 我的想法，先输入用户名，然后比较不对的话就立刻告知对方
 */
public class LoginSimulation {
    public static void main(String[] args) {
        String name = "bamboo";
        String password = "13452";
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入用户名和密码");
        int count = 3;
        for (int i = 0; i < 3; i++) {
            String name1 = sc.next();
            String password2 = sc.next();
            if (!name1.equals(name) || !password2.equals(password)) {
                count -= 1;
                System.out.println("您输入的用户名或密码有误,你还有" + count + "次机会");
            }
            if (name1.equals(name) && password2.equals(password)) {
                System.out.println("恭喜你，登陆成功！");
                break;
            }
        }
    }
}
